import React, {FC} from 'react';
import {QuestionCheckboxDefaultProps, QuestionCheckboxPropsType} from "./interface";
import {Checkbox, Space, Typography} from "antd";

const {Paragraph} = Typography
const QuestionCheckbox: FC<QuestionCheckboxPropsType> = (props: QuestionCheckboxPropsType) => {
  const {title = '', isVertical = false, List = []} = {...QuestionCheckboxDefaultProps, ...props}

  return (
    <div>
      <Paragraph strong>{title}</Paragraph>
      <Space direction={isVertical ? 'vertical' : 'horizontal'}>
        {
          List.map((item, index) => {
            const {text, value, checked} = item
            return <Checkbox value={value} key={index} checked={checked}>{text}</Checkbox>
          })
        }
      </Space>
    </div>
  );
};

export default QuestionCheckbox;
